use generator_prompts::SimplePromptGenerator;
use model_graph_types::{
    assistant::prompts::{
        PromptGenerateOptionsBuilder, PromptGenerator, PromptGeneratorBuildInTemplate,
    },
    database::{ConnectorProtocol, DataSource as DatabaseDataSource, DatabaseType},
    modeling::{set_system_meta_database, Value},
};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    tracing_subscriber::fmt()
        .with_max_level(tracing::Level::DEBUG)
        .init();
    tracing::info!("RRAI 启动...");

    set_system_meta_database(DatabaseDataSource {
        id: 0,
        database_type: DatabaseType::SQLite,
        protocol: ConnectorProtocol::SQLite,
        url: String::from("sqlite:/Users/jinisu/rrg01/rrg01.sqlite"),
        ..Default::default()
    })?;

    let res = SimplePromptGenerator::default()
        .generate_with_buildin(
            PromptGeneratorBuildInTemplate::CodeClass,
            &String::from("任务调度系统"),
            PromptGenerateOptionsBuilder::default().build()?,
        )
        .await;

    match res {
        Ok(response) => {
            tracing::debug!("1{:?}", response);
        }
        Err(err) => {
            tracing::error!("2{:?}", err);
        }
    }
    tokio::select! {
        _ = tokio::signal::ctrl_c() => {
            println!();
        }
    };
    tracing::info!("RRAI 结束...");
    Ok(())
}
